#7-3 与7无关的数【组合数据类型】
def seven(num):
    if num % 7 == 0:
        return True
    while num > 0:
        if num % 10 == 7:
            return True
        num = num // 10
    return False
s=input()
k=[]
sum=0
for i in range(int(s)):
    if seven(i):
        continue
    else:
        k.append(i)
        if i<100:
            sum+=i*i
print(k)
print(sum,end="")